Skip to content

Fix incorrect flattening behavior for hidden nodes#3759

Draft
JustJ01 wants to merge 5 commits intoGraphiteEditor:masterfrom
JustJ01:fix-hidden-node-flattening
Draft

Fix incorrect flattening behavior for hidden nodes#3759
JustJ01 wants to merge 5 commits intoGraphiteEditor:masterfrom
JustJ01:fix-hidden-node-flattening

Conversation

@JustJ01
Copy link
Contributor

@JustJ01 JustJ01 commented Feb 13, 2026

Closes #3629

When a node like Instance Position or Pointer Position is hidden, the flattening logic incorrectly replaces it with a default () value.

This causes:

  • Type mismatches in downstream nodes (Ex ConvertNode<DVec2>)
  • Graph evaluation failures
  • Panics such as:
    • Cannot construct default value for hidden node
    • entered unreachable code: tried to resolve not flattened node

Before:

Expected Behavior

Hiding a node should:

  • Preserve its output type
  • Forward a compatible input when possible
  • Never inject () unless the node’s real output type is ()

Solution

Screen.Recording.2026-02-14.021205.mp4

Updated flatten_with_fns handling for Visible::Value(output_type).

New behavior:

  1. If a compatible input exists

    • Replace the node with an identity node
    • Forward that input directly
    • Preserve type integrity
  2. If no compatible input exists

    • Generate a default value using:
      TaggedValue::from_type(&output_type)
    • Insert a correctly typed constant node
  3. Prevent incorrect () propagation

    • The logic no longer defaults to () unless the node’s actual output type is unit.

Result

  • Hiding Instance Position no longer crashes.
  • ConvertNode<DVec2> no longer receives ().

@JustJ01 JustJ01 marked this pull request as ready for review February 14, 2026 16:18

#[derive(Clone, Debug, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
pub enum Visible {
Passthrough,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passthrough means to use the current hiding logic, where it is replaced with a Passthrough node

};
let Some(node) = network.nodes.get_mut(node_id) else {
log::error!("Could not get node {node_id} in set_visibility");
if is_visible {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is generally wrong. For nodes with no inputs, we want to use the downstream traversal and type lookup solution. For nodes with any number of inputs they just become pass through nodes as is the current behavior.

@Keavon Keavon marked this pull request as draft February 14, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when hiding an 'Instance Position' or 'Pointer Position' node feeding a value

2 participants